﻿#region Imports
using System.Windows.Forms;
using CommonUtilities.Util;
#endregion

namespace CommonUtilities.Controls
{
    /// <summary>
    /// CommonUtilities ToolTip
    /// (inherited from System.Windows.Forms.ToolTip)
    /// </summary>
    public class CUtil_InvalidPathTooltip : ToolTip
    {
        #region Properties
        /// <summary>
        /// Tooltip text
        /// </summary>
        public string TooltipText { get; set; }

        /// <summary>
        /// Parent System.Windows.Forms.Control to display the ToolTip for
        /// </summary>
        public Control ParentControl { get; set; }
        #endregion

        #region Constructors
        /// <summary>
        /// Customized constructor
        /// </summary>
        /// <param name="control">Parent System.Windows.Forms.Control to display the ToolTip for</param>
        public CUtil_InvalidPathTooltip(Control control)
            : base()
        {
            this.ParentControl = control;
            this.ToolTipTitle = "Error:";
            this.ToolTipIcon = ToolTipIcon.Error;
            this.ShowAlways = true;
            this.UseAnimation = true;
            this.UseFading = true;

            TooltipText = "Cannot contain any of the following:" + Utilities.cNewLine
                + @"\ / : * ? "" <> |";
        }
        #endregion

        #region Methods
        /// <summary>
        /// Shows tooltip
        /// </summary>
        /// <param name="duration">Duration to display tooltip (default 1500)</param>
        public void ShowToolTip(int duration = 1500)
        {
            this.Show(TooltipText, ParentControl, duration);
        }

        /// <summary>
        /// Hides tooltip
        /// </summary>
        public void HideToolTip()
        {
            this.Hide(ParentControl);
        }

        public override string ToString()
        {
            return Utilities.ToString(this);
        }
        #endregion
    }
}
